#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>

#include <cgicc/CgiDefs.h>
#include <cgicc/Cgicc.h>
#include <cgicc/HTTPHTMLHeader.h>
#include <cgicc/HTMLClasses.h>
#include "Request/RequestDispatcher.h"

using namespace std;
using namespace cgicc;

string get_request_param(Cgicc& formData,const string &param){
	form_iterator fi=formData.getElement(param);
   	string res;
   	if(!fi->isEmpty() && fi!=(*formData).end()){
   		string temp="";
   		temp=**fi;
   		res=temp;
   	}
   	return res;
}

int main()
{
	Cgicc formData;
	string json=get_request_param(formData,"data");
	RequestDispatcher *dispatcher=new  RequestDispatcher();
	cout<< "Content-type:text/html;charset=utf-8\r\n\r\n"<<endl;
	cout<<dispatcher->dispatchRequest(json)<<endl;
	return 0;
}